#!/usr/bin/perl -w
print "Which directory? (Default is your home directory)";
chomp(my $dir=<STDIN>);
if ($dir =~ /\A\s*\z/){
    chdir or die"Can't chdir to your home directory: $!";
} else {
    chdir $dir or die "Can't chdir to '$dir':$!";
}

my @files = <*>;
foreach(@files){
    print "$_\n";
}
